<template>
  <div>
    <el-card>
      <el-row :gutter="10">
        <el-col :span="3">
          <el-button type="primary" v-if="addBtn" size="medium" @click="openAddPage">添加</el-button>
        </el-col>
      </el-row>

      <el-table :data="attendanceDicData" style="width: 100%;">
        <el-table-column type="index"></el-table-column>
        <el-table-column prop="absenteeism" label="矿工扣考勤(天)" width="120"></el-table-column>
        <el-table-column prop="attendanceA_Morefrom" label="A+分数(从)" width="100"></el-table-column>
        <el-table-column prop="attendanceA_Moreto" label="A+分数(至)" width="100"></el-table-column>
        <el-table-column prop="attendance_A_More_Factor" label="A+年考勤系数" width="120"></el-table-column>
        <el-table-column prop="attendance_A_More_Level_Factor" label="A+考勤系数" width="120"></el-table-column>

        <el-table-column prop="attendanceAfrom" label="A分数(从)" width="100"></el-table-column>
        <el-table-column prop="attendanceAto" label="A分数(至)" width="100"></el-table-column>

        <el-table-column prop="attendance_A_Factor" label="A年考勤系数" width="120"></el-table-column>
        <el-table-column prop="attendance_A_level_Factor" label="A考勤系数" width="120"></el-table-column>

        <el-table-column prop="attendanceBfrom" label="B分数(从)" width="90"></el-table-column>
        <el-table-column prop="attendanceBto" label="B分数(至)" width="90"></el-table-column>

        <el-table-column prop="attendance_B_Factor" label="B年考勤系数" width="120"></el-table-column>
        <el-table-column prop="attendance_B_level_Factor" label="B考勤系数" width="120"></el-table-column>

        <el-table-column prop="attendanceCfrom" label="C分数(从)" width="90"></el-table-column>
        <el-table-column prop="attendanceCto" label="C分数(至)" width="90"></el-table-column>

        <el-table-column prop="attendance_C_Factor" label="C年考勤系数" width="100"></el-table-column>
        <el-table-column prop="attendance_C_level_Factor" label="C考勤系数" width="90"></el-table-column>

        <el-table-column prop="attendanceDfrom" label="D分数(从)" width="90"></el-table-column>
        <el-table-column prop="attendanceDto" label="D分数(至)" width="90"></el-table-column>

        <el-table-column prop="attendance_D_Factor" label="D年考勤系数" width="105"></el-table-column>
        <el-table-column prop="attendance_D_level_Factor" label="D考勤系数" width="90"></el-table-column>

        <el-table-column prop="lateOnce_Money" label="迟到扣薪资" width="90"></el-table-column>
        <el-table-column prop="lateTimes_to_be_Aday" label="迟到N次扣1天考勤" width="140"></el-table-column>
        <el-table-column prop="workAgeMoeny" label="工龄工资" width="90"></el-table-column>
        <el-table-column prop="maxWorkAgeMoeny" label="最大工龄工资" width="110"></el-table-column>

        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button type="text" size="small" @click="openUpdatePage(scope.row.id)">修改</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
    <el-dialog title="添加考勤字典" :visible.sync="dialogaddVisible" width="30%">
      <el-form
        ref="attendanceDicAddForm"
        :model="attendanceDicAddForm"
        :rules="attendanceDicFormRules"
        label-width="150px"
      >
        <el-form-item label="部门">
          <el-input v-model="this.deapertName" size="small" readonly style="width:128px;"></el-input>
        </el-form-item>

        <el-form-item label="矿工扣考勤(天)" prop="absenteeism">
          <el-input-number
            v-model="attendanceDicAddForm.absenteeism"
            :precision="2"
            :step="0.5"
            :max="100"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>
        <el-form-item label="迟到扣薪资" prop="lateOnce_Money">
          <el-input-number
            v-model="attendanceDicAddForm.lateOnce_Money"
            :precision="2"
            :step="50"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>
        <el-form-item label="迟到N次扣1天考勤" prop="lateTimes_to_be_Aday">
          <el-input-number
            v-model="attendanceDicAddForm.lateTimes_to_be_Aday"
            :precision="0"
            :step="1"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>

        <el-form-item label="A+分数(从)" prop="attendanceA_Morefrom">
          <el-input-number
            v-model="attendanceDicAddForm.attendanceA_Morefrom"
            :precision="2"
            :step="1"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>
        <el-form-item label="A+分数(至)" prop="attendanceA_Moreto">
          <el-input-number
            v-model="attendanceDicAddForm.attendanceA_Moreto"
            :precision="2"
            :step="1"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>

        <el-form-item label="A+年考勤系数" prop="attendance_A_More_Factor">
          <el-input-number
            v-model="attendanceDicAddForm.attendance_A_More_Factor"
            :precision="2"
            :step="0.1"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>
        <el-form-item label="A+考勤系数" prop="attendance_A_More_Level_Factor">
          <el-input-number
            v-model="attendanceDicAddForm.attendance_A_More_Level_Factor"
            :precision="2"
            :step="0.1"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>

        <el-form-item label="A分数(从)" prop="attendanceAfrom">
          <el-input-number
            v-model="attendanceDicAddForm.attendanceAfrom"
            :precision="2"
            :step="1"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>
        <el-form-item label="A分数(至)" prop="attendanceAto">
          <el-input-number
            v-model="attendanceDicAddForm.attendanceAto"
            :precision="2"
            :step="1"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>
        <el-form-item label="A年考勤系数" prop="attendance_A_Factor">
          <el-input-number
            v-model="attendanceDicAddForm.attendance_A_Factor"
            :precision="2"
            :step="0.1"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>
        <el-form-item label="A考勤系数" prop="attendance_A_level_Factor">
          <el-input-number
            v-model="attendanceDicAddForm.attendance_A_level_Factor"
            :precision="2"
            :step="0.1"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>

        <el-form-item label="B分数(从)" prop="attendanceBfrom">
          <el-input-number
            v-model="attendanceDicAddForm.attendanceBfrom"
            :precision="2"
            :step="1"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>
        <el-form-item label="B分数(至)" prop="attendanceBto">
          <el-input-number
            v-model="attendanceDicAddForm.attendanceBto"
            :precision="2"
            :step="1"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>
        <el-form-item label="B年考勤系数" prop="attendance_B_Factor">
          <el-input-number
            v-model="attendanceDicAddForm.attendance_B_Factor"
            :precision="2"
            :step="0.1"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>
        <el-form-item label="B考勤系数" prop="attendance_B_level_Factor">
          <el-input-number
            v-model="attendanceDicAddForm.attendance_B_level_Factor"
            :precision="2"
            :step="0.1"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>

        <el-form-item label="C分数(从)" prop="attendanceCfrom">
          <el-input-number
            v-model="attendanceDicAddForm.attendanceCfrom"
            :precision="2"
            :step="1"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>
        <el-form-item label="C分数(至)" prop="attendanceCto">
          <el-input-number
            v-model="attendanceDicAddForm.attendanceCto"
            :precision="2"
            :step="1"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>
        <el-form-item label="C年考勤系数" prop="attendance_C_Factor">
          <el-input-number
            v-model="attendanceDicAddForm.attendance_C_Factor"
            :precision="2"
            :step="0.1"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>
        <el-form-item label="C考勤系数" prop="attendance_C_level_Factor">
          <el-input-number
            v-model="attendanceDicAddForm.attendance_C_level_Factor"
            :precision="2"
            :step="0.1"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>

        <el-form-item label="D分数(从)" prop="attendanceDfrom">
          <el-input-number
            v-model="attendanceDicAddForm.attendanceDfrom"
            :precision="2"
            :step="1"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>
        <el-form-item label="D分数(至)" prop="attendanceDto">
          <el-input-number
            v-model="attendanceDicAddForm.attendanceDto"
            :precision="2"
            :step="1"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>
        <el-form-item label="D年考勤系数" prop="attendance_D_Factor">
          <el-input-number
            v-model="attendanceDicAddForm.attendance_D_Factor"
            :precision="2"
            :step="0.1"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>
        <el-form-item label="D考勤系数" prop="attendance_D_level_Factor">
          <el-input-number
            v-model="attendanceDicAddForm.attendance_D_level_Factor"
            :precision="2"
            :step="0.1"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>
        <el-form-item label="工龄工资" prop="workAgeMoeny">
          <el-input-number
            v-model="attendanceDicForm.workAgeMoeny"
            :precision="2"
            :step="10"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>

        <el-form-item label="最大工龄工资" prop="maxWorkAgeMoeny">
          <el-input-number
            v-model="attendanceDicForm.maxWorkAgeMoeny"
            :precision="2"
            :step="10"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" :disabled="isadddisabled" @click="addForm()">提交</el-button>
          <el-button @click="resetAddForm()">重置</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>

    <el-dialog title="修改考勤字典" :visible.sync="dialogVisible" width="40%">
      <el-form
        ref="attendanceDicForm"
        :model="attendanceDicForm"
        :rules="attendanceDicFormRules"
        label-width="150px"
      >
        <el-form-item label="部门">
          <el-input v-model="this.deapertName" size="small" readonly style="width:128px;"></el-input>
        </el-form-item>

        <el-form-item label="矿工扣考勤(天)" prop="absenteeism">
          <el-input-number
            v-model="attendanceDicForm.absenteeism"
            :precision="2"
            :step="0.5"
            :max="100"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>
        <el-form-item label="迟到扣薪资" prop="lateOnce_Money">
          <el-input-number
            v-model="attendanceDicForm.lateOnce_Money"
            :precision="2"
            :step="50"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>
        <el-form-item label="迟到N次扣1天考勤" prop="lateTimes_to_be_Aday">
          <el-input-number
            v-model="attendanceDicForm.lateTimes_to_be_Aday"
            :precision="0"
            :step="1"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>

        <el-form-item label="A+分数(从)" prop="attendanceA_Morefrom">
          <el-input-number
            v-model="attendanceDicForm.attendanceA_Morefrom"
            :precision="2"
            :step="1"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>
        <el-form-item label="A+分数(至)" prop="attendanceA_Moreto">
          <el-input-number
            v-model="attendanceDicForm.attendanceA_Moreto"
            :precision="2"
            :step="1"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>

        <el-form-item label="A+年考勤系数" prop="attendance_A_More_Factor">
          <el-input-number
            v-model="attendanceDicForm.attendance_A_More_Factor"
            :precision="2"
            :step="0.1"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>
        <el-form-item label="A+考勤系数" prop="attendance_A_More_Level_Factor">
          <el-input-number
            v-model="attendanceDicForm.attendance_A_More_Level_Factor"
            :precision="2"
            :step="0.1"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>

        <el-form-item label="A分数(从)" prop="attendanceAfrom">
          <el-input-number
            v-model="attendanceDicForm.attendanceAfrom"
            :precision="2"
            :step="1"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>
        <el-form-item label="A分数(至)" prop="attendanceAto">
          <el-input-number
            v-model="attendanceDicForm.attendanceAto"
            :precision="2"
            :step="1"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>
        <el-form-item label="A年考勤系数" prop="attendance_A_Factor">
          <el-input-number
            v-model="attendanceDicForm.attendance_A_Factor"
            :precision="2"
            :step="0.1"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>
        <el-form-item label="A考勤系数" prop="attendance_A_level_Factor">
          <el-input-number
            v-model="attendanceDicForm.attendance_A_level_Factor"
            :precision="2"
            :step="0.1"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>

        <el-form-item label="B分数(从)" prop="attendanceBfrom">
          <el-input-number
            v-model="attendanceDicForm.attendanceBfrom"
            :precision="2"
            :step="1"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>
        <el-form-item label="B分数(至)" prop="attendanceBto">
          <el-input-number
            v-model="attendanceDicForm.attendanceBto"
            :precision="2"
            :step="1"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>
        <el-form-item label="B年考勤系数" prop="attendance_B_Factor">
          <el-input-number
            v-model="attendanceDicForm.attendance_B_Factor"
            :precision="2"
            :step="0.1"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>
        <el-form-item label="B考勤系数" prop="attendance_B_level_Factor">
          <el-input-number
            v-model="attendanceDicForm.attendance_B_level_Factor"
            :precision="2"
            :step="0.1"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>

        <el-form-item label="C分数(从)" prop="attendanceCfrom">
          <el-input-number
            v-model="attendanceDicForm.attendanceCfrom"
            :precision="2"
            :step="1"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>
        <el-form-item label="C分数(至)" prop="attendanceCto">
          <el-input-number
            v-model="attendanceDicForm.attendanceCto"
            :precision="2"
            :step="1"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>
        <el-form-item label="C年考勤系数" prop="attendance_C_Factor">
          <el-input-number
            v-model="attendanceDicForm.attendance_C_Factor"
            :precision="2"
            :step="0.1"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>
        <el-form-item label="C考勤系数" prop="attendance_C_level_Factor">
          <el-input-number
            v-model="attendanceDicForm.attendance_C_level_Factor"
            :precision="2"
            :step="0.1"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>

        <el-form-item label="D分数(从)" prop="attendanceDfrom">
          <el-input-number
            v-model="attendanceDicForm.attendanceDfrom"
            :precision="2"
            :step="1"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>
        <el-form-item label="D分数(至)" prop="attendanceDto">
          <el-input-number
            v-model="attendanceDicForm.attendanceDto"
            :precision="2"
            :step="1"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>
        <el-form-item label="D年考勤系数" prop="attendance_D_Factor">
          <el-input-number
            v-model="attendanceDicForm.attendance_D_Factor"
            :precision="2"
            :step="0.1"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>
        <el-form-item label="D考勤系数" prop="attendance_D_level_Factor">
          <el-input-number
            v-model="attendanceDicForm.attendance_D_level_Factor"
            :precision="2"
            :step="0.1"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>

        <el-form-item label="工龄工资" prop="workAgeMoeny">
          <el-input-number
            v-model="attendanceDicForm.workAgeMoeny"
            :precision="2"
            :step="10"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>

        <el-form-item label="最大工龄工资" prop="maxWorkAgeMoeny">
          <el-input-number
            v-model="attendanceDicForm.maxWorkAgeMoeny"
            :precision="2"
            :step="10"
            :min="0"
            size="small"
          ></el-input-number>
        </el-form-item>

        <el-form-item>
          <el-button type="primary" :disabled="isdisabled" @click="updateForm()">提交</el-button>
          <el-button @click="resetupdateForm()">重置</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>
<script>
export default {
  data() {
    return {
      isdisabled: false,
      addBtn: false,
      corpId: null,
      code: null,
      departId: null,
      deapertName: null,
      attendanceDicData: null,
      dialogVisible: false,
      dialogaddVisible: false,
      isadddisabled: false,
      attendanceDicAddForm: {
        departId: null,
        absenteeism: 0,
        attendanceA_Morefrom: 0,
        attendanceA_Moreto: null,
        attendance_A_More_Factor: null,
        attendance_A_More_Level_Factor: null,
        attendanceAfrom: null,
        attendanceAto: null,
        attendance_A_Factor: null,
        attendance_A_level_Factor: null,
        attendanceBfrom: null,
        attendanceBto: null,
        attendance_B_Factor: null,
        attendance_B_level_Factor: null,
        attendanceCfrom: null,
        attendanceCto: null,
        attendance_C_Factor: null,
        attendance_C_level_Factor: null,
        attendanceDfrom: null,
        attendanceDto: null,
        attendance_D_Factor: null,
        attendance_D_level_Factor: null,
        lateOnce_Money: null,
        lateTimes_to_be_Aday: null
      },
      attendanceDicForm: {
        id: null,
        absenteeism: null,
        attendanceA_Morefrom: null,
        attendanceA_Moreto: null,
        attendance_A_More_Factor: null,
        attendance_A_More_Level_Factor: null,
        attendanceAfrom: null,
        attendanceAto: null,
        attendance_A_Factor: null,
        attendance_A_level_Factor: null,
        attendanceBfrom: null,
        attendanceBto: null,
        attendance_B_Factor: null,
        attendance_B_level_Factor: null,
        attendanceCfrom: null,
        attendanceCto: null,
        attendance_C_Factor: null,
        attendance_C_level_Factor: null,
        attendanceDfrom: null,
        attendanceDto: null,
        attendance_D_Factor: null,
        attendance_D_level_Factor: null,
        lateOnce_Money: null,
        lateTimes_to_be_Aday: null
      },
      attendanceDicFormRules: {
        absenteeism: [
          { required: true, message: "请填写矿工扣考勤(天)", trigger: "blur" }
        ],
        attendanceA_Morefrom: [
          { required: true, message: "请填写A+分数(从)", trigger: "blur" }
        ],
        attendanceA_Moreto: [
          { required: true, message: "请填写A+分数(至)", trigger: "blur" }
        ],
        attendance_A_More_Factor: [
          { required: true, message: "请填写A+年考勤系数", trigger: "blur" }
        ],
        attendance_A_More_Level_Factor: [
          { required: true, message: "请填写A+考勤系数", trigger: "blur" }
        ],
        attendanceAfrom: [
          { required: true, message: "请填写A分数(从)", trigger: "blur" }
        ],
        attendanceAto: [
          { required: true, message: "请填写A分数(至)", trigger: "blur" }
        ],
        attendance_A_Factor: [
          { required: true, message: "请填写A年考勤系数", trigger: "blur" }
        ],
        attendance_A_level_Factor: [
          { required: true, message: "请填写A考勤系数", trigger: "blur" }
        ],
        attendanceBfrom: [
          { required: true, message: "请填写B分数(从)", trigger: "blur" }
        ],
        attendanceBto: [
          { required: true, message: "请填写B分数(至)", trigger: "blur" }
        ],
        attendance_B_Factor: [
          { required: true, message: "请填写B年考勤系数", trigger: "blur" }
        ],
        attendance_B_level_Factor: [
          { required: true, message: "请填写B考勤系数", trigger: "blur" }
        ],
        attendanceCfrom: [
          { required: true, message: "请填写C分数(从)", trigger: "blur" }
        ],
        attendanceCto: [
          { required: true, message: "请填写C分数(至)", trigger: "blur" }
        ],
        attendance_C_Factor: [
          { required: true, message: "请填写C年考勤系数", trigger: "blur" }
        ],
        attendance_C_level_Factor: [
          { required: true, message: "请填写C考勤系数", trigger: "blur" }
        ],
        attendanceDfrom: [
          { required: true, message: "请填写D分数(从)", trigger: "blur" }
        ],
        attendanceDto: [
          { required: true, message: "请填写D分数(至)", trigger: "blur" }
        ],
        attendance_D_Factor: [
          { required: true, message: "请填写D年考勤系数", trigger: "blur" }
        ],
        attendance_D_level_Factor: [
          { required: true, message: "请填写D考勤系数", trigger: "blur" }
        ],
        lateOnce_Money: [
          { required: true, message: "请填写迟到扣薪资", trigger: "blur" }
        ],
        lateTimes_to_be_Aday: [
          { required: true, message: "请填写迟到N次扣1天考勤", trigger: "blur" }
        ]
      }
    };
  },
  created: function() {
    this.getJsApiTeckit();
  },
  methods: {
    async getJsApiTeckit() {
      var result = await this.$httpd.get("/DingDingSecurity/GetJsapiTicket");
      if (result.status != 200) {
        this.$message.error("获取钉钉信息出错");
        return;
      }
      this.corpId = result.data.corpId;
      this.getCode(this.corpId);
    },
    //获取个人免登code
    getCode(corpId) {
      var that = this;
      that.$dd.ready(() => {
        that.$dd.runtime.permission.requestAuthCode({
          corpId: corpId, // 企业id
          onSuccess: function(info) {
            that.code = info.code;
            that.getDeparts(that.code);
          }
        });
      });
    },
    async getDeparts(code) {
      var result = await this.$httpd.get(
        `/EmpSalary/GetdepartmentById?code=${code}`
      );
      if (result.status != 200) {
        this.$message.error("获取部门数据出错");
        return;
      }
      this.departId = result.data.id;
      this.deapertName = result.data.name;
      //
      this.getAttendanceDic(this.departId);
    },
    async getAttendanceDic(dePartId) {
      var result = await this.$httpd.get(
        `/AttendanceDictionary/GetAttendaceDictionary?dePartId=${dePartId}`
      );
      if (result.status != 200 || result.data.returnStatus == 0) {
        this.$message.error(result.data.message);
        return;
      }
      this.attendanceDicData = result.data.data;

      if (result.data.data.length != 0) {
        this.addBtn = false;
      } else {
        this.addBtn = true;
      }
    },
    async openUpdatePage() {
      this.dialogVisible = true;
      this.isdisabled = false;
      var result = await this.$httpd.get(
        `/AttendanceDictionary/GetAttendaceDictionary?dePartId=${this.departId}`
      );
      if (result.status != 200 || result.data.returnStatus == 0) {
        this.$message.error(result.data.message);
        return;
      }
      this.attendanceDicForm = result.data.data[0];
    },
    async updateForm() {
      this.$refs.attendanceDicForm.validate(async v => {
        if (v) {
          this.isdisabled = true;
          var result = await this.$httpd.post(
            "/AttendanceDictionary/Update",
            this.attendanceDicForm
          );
          if (result.status != 200 || result.data.returnStatus == 0) {
            this.$message.error(result.data.message);
            return;
          }
          this.dialogVisible = false;
          this.getAttendanceDic(this.departId);
          this.$message.success({
            message: result.data.message,
            type: "success"
          });
        }
      });
    },
    resetupdateForm() {
      this.$refs.attendanceDicForm.resetFields();
    },
    resetAddForm() {
      this.$refs.attendanceDicAddForm.resetFields();
    },
    openAddPage() {
      this.dialogaddVisible = true;
      this.isadddisabled = false;
    },
    async addForm() {
      this.$refs.attendanceDicAddForm.validate(async v => {
        if (v) {
          this.attendanceDicAddForm.departId = this.departId;
          this.isadddisabled = true;
          var result = await this.$httpd.post(
            "/AttendanceDictionary/Add",
            this.attendanceDicAddForm
          );
          if (result.status != 200 || result.data.returnStatus == 0) {
            this.$message.error(result.data.message);
            return;
          }
          this.dialogaddVisible = false;
          this.getAttendanceDic(this.departId);
          this.$message.success({
            message: result.data.message,
            type: "success"
          });
        }
      });
    }
  }
};
</script>